import React, { Component } from 'react'
import {update} from '../../api/health'
import {
  Form,
  Button,
  Radio
} from 'antd'
export default class Information extends Component {

  state = {
    contact:2,
    temperature:1,
    symptom:1,
    isout:1

  }
  // onFinish = (values) => {
  //   console.log('onfinish',values);
  //   const stuNo1 = localStorage.getItem('stuNo')
  //   const stuNo = Number(stuNo1)
  //   const {contact,temperature,symptom,isout} = this.state
  //   console.log(stuNo,contact,temperature,symptom,isout)
  //   update(stuNo,contact,temperature,symptom,isout)
  // };

  Submit =() => {
    const {contact,temperature,symptom,isout} = this.state
      const stuNo1 = localStorage.getItem('stuNo')
    const stuNo = Number(stuNo1)
    console.log(stuNo,contact,temperature,symptom,isout)
    update({stuNo,contact,temperature,symptom,isout})
  }

   onChange1 = e => {
    console.log('radio1 checked', e.target.value);
    console.log('this.state',this.state)
    this.setState({
      symptom:e.target.value
    } )
  };
  onChange2 = e => {
    console.log('radio1 checked', e.target.value);
    console.log('this.state',this.state)
    this.setState({
      isout:e.target.value
    } )
  };
  onChange3 = e => {
    console.log('radio1 checked', e.target.value);
    console.log('this.state',this.state)
    this.setState({
      temperature:e.target.value
    } )
  };
  onChange4 = e => {
    console.log('radio1 checked', e.target.value);
    console.log('this.state',this.state)
    this.setState({
      symptom:e.target.value
    } )
  };
  render() {
    const {contact,temperature,symptom,isout} = this.state
    return (
      <div style={{ width: '1000px', height: '800px', marginLeft:'230px'}}>
        <div style={{width:'300px ',marginLeft:'300px'}}>信息提报</div> 
      <Form
        name="health-ref"
        className="health-ref"
        labelCol={{ span: 4 }}
        wrapperCol={{ span: 14 }}
        layout="horizontal"
        onFinish={this.onFinish}
        initialValues={{
          contact:2,
          temperature:1,
          symptom:1,
          isout:1
        }}
        onSubmit
      >
        <Form.Item label="是否有新冠肺炎相关症状" name="symptom">
        <Radio.Group  onChange={this.onChange1} value={symptom}>
          <Radio value={2}>是</Radio>
          <Radio value={1}>否</Radio>
        </Radio.Group>
        
        </Form.Item>
        <Form.Item label="是否返校" name="isout">
        <Radio.Group onChange={this.onChange2} value={isout}>
          <Radio value={1}>是</Radio>
          <Radio value={2}>否</Radio>
        </Radio.Group>
        
        </Form.Item>
        <Form.Item label="当前体温" name="temperature">
        <Radio.Group onChange={this.onChange3} value={temperature}>
          <Radio value={1}>正常（小于37.3℃）</Radio>
          <Radio value={2}>否（大于等于37.3℃）</Radio>
        </Radio.Group>
        </Form.Item>
        <Form.Item label="是否接触新冠疑似病例" name="contact">
        <Radio.Group onChange={this.onChange4} value={contact}>
          <Radio value={1}>是</Radio>
          <Radio value={2}>否</Radio>
        </Radio.Group>
        </Form.Item>
        
          <Button type="primary" htmlType="submit" style={{marginLeft:'300px'}} onClick={this.Submit}>提交</Button>
        
      </Form>
      </div>
    )
  }
}
